import SwiftUI

// MARK: - AsyncImage Extension for better error handling
extension View {
    func asyncImage(urlString: String?, contentMode: ContentMode = .fill) -> some View {
        Group {
            if let urlString = urlString, let url = URL(string: urlString) {
                AsyncImage(url: url) { image in
                    image
                        .resizable()
                        .aspectRatio(contentMode: contentMode)
                } placeholder: {
                    Rectangle()
                        .fill(Color.gray.opacity(0.3))
                }
            } else {
                Rectangle()
                    .fill(Color.gray.opacity(0.3))
            }
        }
    }
}